#ifndef __MUTEX_H__
#define __MUTEX_H__

#include <coil/Mutex.h>
#include <utils/MutexCond.h>

struct ScopedLock {
    ScopedLock(coil::Mutex &m) :m_lock(m) {m_lock.lock();}
    ~ScopedLock() {m_lock.unlock();}
    coil::Mutex &m_lock;
};

struct ScopedCondLock {
    ScopedCondLock(coil::Mutex &m, MutexCond &mc) : m_lock(m), m_cond(mc)  {m_lock.lock(); m_cond.wait(m_lock);}
    ~ScopedCondLock() {m_lock.unlock();}
    coil::Mutex &m_lock;    
    MutexCond &m_cond;
};

#endif
